import os
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox
from PyQt5.QtCore import Qt
from card_list_app import CardListApp
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
def handle_exception(exc_type, exc_value, traceback):
    QMessageBox.critical(
        None,
        "程序异常",
        f"发生未捕获异常:\n\n类型: {exc_type.__name__}\n详情: {exc_value}"
    )
    sys.__excepthook__(exc_type, exc_value, traceback)

if __name__ == '__main__':
    # 启用高DPI缩放
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)

    # 设置全局异常钩子
    sys.excepthook = handle_exception

    app = QApplication(sys.argv)
    ex = CardListApp()
    ex.show()
    sys.exit(app.exec_())
